import cv2
video=cv2.VideoCapture("yzbf.mp4")  #打开视频
while(video.isOpened()):
    retval,image=video.read()   #读取帧
    cv2.namedWindow("Video",0)
    cv2.resizeWindow("Video",420,300)
    if retval==True:
        cv2.imshow("Video",image)   #播放
    else:
        break
    key=cv2.waitKey(1)  #窗口等待1ms
    if key==27:         #若按“esc”键，则退出循环
        break
video.release()         #关闭视频
cv2.destroyAllWindows()